package com.merchant.product.controller;


import java.util.List;

import org.merchant.product.weixin.mp.api.WxMpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.merchant.product.config.CommonPropertyConfiguration;
import com.merchant.product.dao.CityDao;
import com.merchant.product.domain.City;
import com.merchant.product.service.TokenService;

@Controller
public class CityController {
	
	@Autowired
	private WxMpService wxService;
	
	@Autowired
	CommonPropertyConfiguration config;
	
    @Autowired
    private CityDao cityDao;

    @RequestMapping(value="cities/pcode", method=RequestMethod.GET)
    public @ResponseBody List<City> findCitiesByPcode(int pcode){
        return cityDao.findCitiesByPcode(pcode);
    }
    
    @RequestMapping(value="/", method=RequestMethod.GET)
    public String index(){
        return "empty/empty";
    }
    
    @RequestMapping(value="/cities", method=RequestMethod.GET)
    public String getArticles(Model model){
    	List<City> codes = cityDao.findAllCities();
    	model.addAttribute("codes", codes);
        return "article/article-management";
    }
    
    
    @RequestMapping(value="/getAppId2", method=RequestMethod.GET)
    public String getAppId2(){
    	System.out.println(config.getAppId());
    	System.out.println(config.getAesKey());
    	System.out.println(config.getSecret());
    	System.out.println(config.getToken());
        return "empty/empty";
    }
    

}
